package com.sunchen.asc.service.user.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.sunchen.asc.service.user.vo.NewUserVo;
import com.sunchen.asc.service.user.vo.UserVo;
import lombok.Data;

import javax.management.relation.Role;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;

@Data
public class UserDto implements Serializable {
    private Long id;
    //姓名
    private String name;
    //用户名
    private String userName;
    //电话
    private String tel;
    //性别
    private int sex;
    //邮箱
    private String email;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp createTime;
    private String createUser;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp deleteTime;
    private String deleteUser;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp updateTime;
    private String updateUser;
    private String password;
    //状态
    private int status;
    //描述
    private String description;

    private List<String> roles;

    public UserDto(){}

    public UserDto(NewUserVo newUserVo) {

        this.name = newUserVo.getName();
        this.userName = newUserVo.getUserName();
        this.tel = newUserVo.getTel();
        this.sex = newUserVo.getSex();
        this.email = newUserVo.getEmail();
        this.status = newUserVo.getStatus();
        this.description = newUserVo.getDescription();
        this.password = newUserVo.getPassword();
    }

    public UserDto(UserVo userVo) {
        this.id = Long.valueOf(userVo.getId());
        this.name = userVo.getName();
        this.userName = userVo.getUserName();
        this.tel = userVo.getTel();
        this.sex = userVo.getSex();
        this.email = userVo.getEmail();
        this.status = userVo.getStatus();
        this.description = userVo.getDescription();
    }
}
